class Solution:
    def reverseWords(self, s: str) -> str:
        s_list = s.strip().split()
        s_list.reverse()
        return " ".join(s_list)


a = Solution()
print(a.reverseWords("the sky is blue"))
print(a.reverseWords("  hello world!  "))
print(a.reverseWords("a good   example"))
